<template>
  <div class="view-wrapper" style="padding: 0">
    <div class="head">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="会员昵称：">
          <el-input
            v-model="formInline.likeKey"
            style="width:200px"
            placeholder="请输入会员昵称、手机号"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" class="sumit_button" @click="search">查询</el-button>
          <el-button @click="reset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="listBox">
      <!-- <div class="listBox_head">
        <export-excel-button
          title="账单列表"
          action="/merchant/bill/v1/bill/export"
          :params="ExportParams"
        />
      </div> -->
      <ex-table
        ref="table"
        :loading="loading"
        :table-column="tableColumn"
        :table-data="tableData"
        @pageSizeChange="handleSizeChange"
        @currentPageChange="handleCurrentChange"
      > 
        <template v-slot:member="{ scope }">
          <div class="slot_box">
            <img class="avatar_img" :src="scope.row.avatar" alt="" v-if="scope.row.avatar!=''" />
            <img class="avatar_img" src="../../../../static/avant.png" v-if="scope.row.avatar==''" alt="" />
            <div>{{ scope.row.nickName }}</div>
          </div>
        </template>
        <template v-slot:operate="{ scope }">
          <el-button @click="lookDetail(scope.row)">查看</el-button>
        </template>
      </ex-table>
    </div>
  </div>
</template>
<script>
// components
import { merchantBgMembers } from "@/api/merchants";
import ExportExcelButton from "@/components/ExportExcelButton/index";
import handlePageMixin from "@/mixins/handlePageMixin";
export default {
  name: "billList",
  components: {
    ExportExcelButton,
  },
  mixins: [handlePageMixin],
  data() {
    return {
      loading: false,
      formInline: {
        likeKey: "",
      },
      date: [],
      options: [
        {
          value: "0",
          label: "请选择",
        },
        {
          value: "1",
          label: "商家名称1",
        },
        {
          value: "2",
          label: "商家名称2",
        },
      ],
      id:'',
      options2: [],
      options3: [],
      tableData: [],
      tableColumn: [
        // { prop: "relevancyNo", label: "会员" },
        {
          prop: "会员",
          slot: true,
          slotName: "member",
          label: "会员",
        },
        { prop: "name", label: "姓名" },
        { prop: "phone", label: "手机号" },
        { prop: "consumeMoney", label: "累计消费金额" },
        { prop: "shareholderCardCount", label: "预付卡数量" },
        { prop: "shareholderCardBalance", label: "股东卡余额", width: 120 },
        { prop: "chargeCardBalanceCount", label: "计费卡余额", width: 120 },
        { prop: "numberCardUsableCount", label: "计次卡剩余", width: 120 },
        { prop: "classHourCardUsableCount", label: "课时卡剩余", width: 120 },
        { prop: "surplusTimeCount", label: "计时卡剩余", width: 120 },
        { label: "操作", slot: true, slotName: "operate" },
      ],
    };
  },
  computed: {
    ExportParams() {
      const { id: ticketId } = this;
      const params = {
        ...this.pageOptions,
        ...this.formInline,
        merchantId: this.id,
      };
      return params;
    },
  },
  created() {
    let query = this.$route.query;
    this.id = query.id;
    this.getList();
  },
  mounted() {
    
  },
  methods: {
    lookDetail(e) {
      console.log(e);
      this.$router.push({
        path: "/merchants/member-card",
        query: {
          customerId: e.customerId,
          merchantId: e.merchantId
        },
      });
      //   this.$router.push({
      //     path: "/moneyManagement/bill-detail",
      //     query: {
      //       orderId: e.relevancyNo,
      //       type: e.billType,
      //     },
      //   });
    },
    search() {
      //搜索
      console.log(this.formInline);
      this.pageOptions.pageNum = 1;
      this.$refs.table.pageOptions.pageNum = 1;
      this.getList();
    },
    reset() {
      this.formInline = {};
      this.pageOptions.pageNum = 1;
      this.$refs.table.pageOptions.pageNum = 1;
      this.getList();
    },
    getList() {
      //联动信息
      const params = {
        ...this.pageOptions,
        ...this.formInline,
        merchantId: this.id,
      };
      this.loading = true;
      merchantBgMembers(params)
        .then((res) => {
          const { total, records } = res.result;
          //   records.forEach((item) => {

          //   });
          this.tableData = records;
          this.$refs.table.pageOptions.total = total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
  },
};
</script>
<style lang="scss" scoped>
.el-card-title {
  font-size: 20px;
}
.head {
  //   box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
  background-color: #fff;
  border-radius: 8px;
  //   height: 120px;
  padding: 20px 20px 0;
}
.el-form--inline .el-form-item {
  margin-right: 40px;
}
.listBox {
  //   box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
  background-color: #fff;
  border-radius: 8px;
  //   height: 120px;
  padding: 20px 20px;
  margin-top: 10px;
}
.table_list {
  display: flex;
  align-items: center;
  // border: 1px solid #DCDFE6;
  border-radius: 7px;
  width: 220px;
  margin-bottom: 10px;
}
.tableBox {
  width: calc(100% / 3);
  height: 36px;
  text-align: center;
  line-height: 36px;
  color: #303133;
  font-size: 14px;
  border: 1px solid #dcdfe6;
  border-right: 0;
}
.tableBox:first-child {
  border-radius: 7px 0px 0px 7px;
}
.tableBox:last-child {
  border-right: 1px solid #dcdfe6;
  border-radius: 0px 7px 7px 0px;
}
.spchoosetext {
  background-color: #fff4e6;
  color: #ff9300;
  // border: 1px solid #ff9300;
}
.listBox_head {
  margin-bottom: 20px;
  display: flex;
  justify-content: flex-end;
}
.slot_box {
  display: flex;
  align-items: center;
}
.avatar_img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  margin-right: 10px;
}
</style>
